from flask_restful import fields  # type: ignore
from libs.helper import  TimestampField
from .prop_fields_def import prod_prop_fields,prod_fields

brand_fields = {
    "id": fields.String,
    "name": fields.String,
    "pic_file_id": fields.String,
    "PicURL": fields.String,
    "memo": fields.String,
    "seq": fields.Integer,
    "status": fields.Boolean,
    "brief": fields.String,
    "content": fields.String,
    "first_char": fields.String,
    "created_at": TimestampField,
    "updated_at": TimestampField,
}

brand_list_fields={
    "total": fields.Integer,
    "has_more": fields.Boolean,
    "data": fields.List(fields.Nested(brand_fields)),
    "message": fields.String,
}

# category_fields will be defined after this line
base_category_fields = {
    "id": fields.String,
    "name": fields.String,
    "shop_id": fields.String,
    "parent_id": fields.String,
    "icon_file_id": fields.String,
    "IconURL": fields.String,
    "pic_file_id": fields.String,
    "PicURL": fields.String,
    "seq": fields.Integer,
    "level": fields.Integer,
    "status": fields.Boolean,
    "created_at": TimestampField,
    "updated_at": TimestampField,
}

# Delayed definition of category_fields to avoid circular reference
category_fields = {
    "id": fields.String,
    "name": fields.String,
    "shop_id": fields.String,
    "parent_id": fields.String,
    "icon_file_id": fields.String,
    "IconURL": fields.String,
    "pic_file_id": fields.String,
    "PicURL": fields.String,
    "seq": fields.Integer,
    "level": fields.Integer,
    "status": fields.Boolean,
    "brands": fields.List(fields.Nested(brand_fields)),
    "prod_props": fields.List(fields.Nested(prod_prop_fields)),
    "products": fields.List(fields.Nested(prod_fields)),
    "categories": fields.List(fields.Nested(lambda: category_fields)),  # Use lambda for delayed evaluation
    "created_at": TimestampField,
    "updated_at": TimestampField,
}

category_list_fields = {
    "total": fields.Integer,
    "has_more": fields.Boolean,
    "data": fields.List(fields.Nested(base_category_fields)),
}